/**
 * Created on 2007-03-25 18:55
 */
package game.media.audio;

import game.Settings;

import java.applet.AudioClip;

/**
 * @author David Wallin
 */
public class Sound
{
	private AudioClip		m_AudioClip;
	private boolean			m_Playing;
	private Settings		m_Settings;
	
	public Sound(AudioClip audioClip)
	{
		m_AudioClip = audioClip;
		m_Playing = false;
		m_Settings = Settings.INSTANCE;
	}
	
	public void play(boolean play)
	{
		if(play)
		{
			if(!m_Playing)
			{
				if(m_Settings.getSoundOn())
				{
					m_AudioClip.play();
					m_Playing = true;
				}
			}
		}
		else
		{
			if(m_Playing)
			{
				m_AudioClip.stop();
				m_Playing = false;
			}
		}
	}
}
